<script>
import { mapMutations } from 'vuex'
export default {
  onLaunch: function () {
    console.log('App Launch');
    // #ifdef APP-PLUS
    if (plus.runtime.appid !== 'HBuilder') {
      plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {  
          uni.request({  
              url: process.uniEnv.baseUrl+'/updateApp',  
              data: {  
                  version: widgetInfo.version,  
                  name: widgetInfo.name  
              },  
              success: (result) => {  
                  var data = result.data;  
                  if (data.update && data.url) {  
                      uni.downloadFile({  
                          url: data.url,  
                          success: (downloadResult) => {  
                              if (downloadResult.statusCode === 200) {  
                                  plus.runtime.install(downloadResult.tempFilePath, {  
                                      force: false  
                                  }, function() {  
                                      console.log('install success...');  
                                      plus.runtime.restart();  
                                  }, function(e) {  
                                      console.error('install fail...');  
                                  });  
                              }  
                          }  
                      });  
                  }  
              }  
          });  
      });  
    }

    // 一键登录预登陆，可以显著提高登录速度
    uni.preLogin({
      provider: 'univerify',
      success: (res) => {
        // 成功
        this.setUniverifyErrorMsg();
        console.log("preLogin success: ", res);
      },
      fail: (res) => {
        this.setUniverifyLogin(false);
        this.setUniverifyErrorMsg(res.errMsg);
        // 失败
        console.log("preLogin fail res: ", res);
      }
    })
    // #endif
  },
  onShow: function () {
    console.log('App Show')
  },
  onHide: function () {
    console.log('App Hide')
  },
  globalData: {
    test: ''
  },
  methods: {
    ...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin'])
  }
}
</script>

<style lang="scss">
@import "@/common/wczd.scss";

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-size: 26upx;
}
/* #ifndef APP-PLUS-NVUE */
/* uni.css - 通用组件、模板样式库，可以当作一套ui库应用 */
/* @import "./common/uni.css"; */

/* H5 兼容 pc 所需 */
/* #ifdef H5 */
@media screen and (min-width: 768px) {
  body {
    overflow-y: scroll;
    height: 100%;
  }
}

/* 顶栏通栏样式 */
/* .uni-top-window {
	    left: 0;
	    right: 0;
	} */

uni-page-body {
  background-color: #f5f5f5 !important;
  min-height: 100% !important;
  /* height: auto !important; */
}


.uni-top-window uni-tabbar .uni-tabbar {
  background-color: #fff !important;
}

.uni-app--showleftwindow .hideOnPc {
  display: none !important;
}
/* #endif */

/* 以下样式用于 hello uni-app 演示所需 */
page {
  background-color: #f5f5f5;
  height: 100%;
  font-size: 28rpx;
  line-height: 1.8;
}
.fix-pc-padding {
  padding: 0 50px;
}
.uni-header-logo {
  padding: 30rpx;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 10rpx;
}

.uni-header-image {
  width: 100px;
  height: 100px;
}

.uni-hello-text {
  color: #7a7e83;
}

.uni-hello-addfile {
  text-align: center;
  line-height: 300rpx;
  background: #fff;
  padding: 50rpx;
  margin-top: 10px;
  font-size: 38rpx;
  color: #808080;
}
/* #endif*/
</style>
